package com.jinzhi.jzweb.strategy.factory;

import java.math.BigDecimal;
import java.math.RoundingMode;

/*
 *  @author : JingChangTian
 *  @date   : 2023/6/3 14:33
 *  @description : 分值配置
 *
 */
public class SourConfig {

    /**
     * C赛场主题网络设计分值
     */
    public final static double network = 0.05;

    /**
     * C赛场教学活动设计分值
     */
    public final static double teaching = 0.1;

    /**
     * C赛场说课分值
     */
    public final static double lecture = 0.2;

    /**
     * 裁判人数
     */
    public final static Integer number = 3;

    public static Double evaluate(Double s1, Double s2, Double s3){
        Double[] a = {s1,s2,s3};
        Double sum = 0.0;
        Double max = Double.MIN_VALUE;
        Double min = Double.MAX_VALUE;
        Double average = 0.0;
        for(int i=0;i<a.length;i++){
            sum+=a[i];//求数组元素的和
            if(a[i]>max){//找出最大值
                max=a[i];
            }
            if(a[i]<min){//找出最小值
                min=a[i];
            }
        }
        if(sum == 0.0){
            average  = sum;
        }else{
            average = (sum - max-min)/(a.length-2);//和减去最大最小值，之后求平均值
        }
        BigDecimal bd = new BigDecimal(average);

        return  bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();

    }

}
